Skip to content

Fix code for immediately 'new'-ed/invoked class expressions #6004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 9, 2015

Conversation

DanielRosenwasser
Copy link
Member

Fixes #4630.

The entire immediate invocation for creating a class expression needs to be parenthesized to avoid the new operator from taking over the argument list.

Since a function expression doesn't need to be parenthesized before calling, we can just shift the closing paren that surrounds the function expression to also surround the argument list.

In other words, this:

new (function () {
    function Ship() {
    }
    return Ship;
})() // <- watch this line

becomes

new (function () {
    function Ship() {
    }
    return Ship;
}()) // <- see here?

@weswigham
Copy link
Member

👍

DanielRosenwasser added a commit that referenced this pull request Dec 9, 2015
Fix code for immediately 'new'-ed/invoked class expressions
@DanielRosenwasser DanielRosenwasser merged commit ecfeb21 into master Dec 9, 2015
@DanielRosenwasser DanielRosenwasser deleted the IICEs branch December 9, 2015 22:15
@DanielRosenwasser
Copy link
Member Author

@mihailik good call! I've filed microsoft/TypeScript-Handbook#130 in light of this, so I'll have to comb through the documentation. Luckily the playground is tied to the current version of TypeScript, so when this goes out, this will update it as well. 😄

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants